package NGUYENHOANG.JAVA_BASE;

import java.util.Scanner;

public class BT2_2810 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double a,b;
        
        System.out.print("a = ");
        String temp = sc.nextLine();        
        if(temp.isEmpty()){
            System.out.println("Nhập giá trị a");
            return;
        }
            a = Double.parseDouble(temp);

            
        System.out.print("b = ");
        temp = sc.nextLine();
        if(temp.isEmpty()){
            System.out.println("Nhập giá trị b");
            return;
        }
            b = Double.parseDouble(temp);

        System.out.print("Chọn phép toán: +, - , *, !? ");
        sc = new Scanner(System.in);
        String opt = sc.nextLine();
        
        if(opt.isEmpty()){
            System.out.println("Bạn chưa chọn phép toán!");
            return;
        }
        if(opt.equals("+")){
            System.out.println("a + b = "+ (a+b));
        }
        else if(opt.equals("-")){
            System.out.println("a - b = "+ (a-b));
        }
        else if(opt.equals("*")){
            System.out.println("a * b = "+ (a*b));
        }
        else if(opt.equals("/")){
            if(a!=0 && b==0){
                System.out.println("Cannot divide by zero");
            }
            else if(a==0 && b==0){
                System.out.println("Result of function is underfined");
            }
            else{
                System.out.println("a / b = "+ (a/b));
            }
        }		
	}

}
